import { TierCollectionEntity, TierDto } from "../models/tier.model";
import { GlobalService } from "./global.service";


export class UaTierService {
  static PATH = "/ua/tier";

  static getTierList() {
    return new Promise<TierCollectionEntity>(
      (resolve, reject) => {
        wx.request({
          url: `${GlobalService.HOST}${UaTierService.PATH}/collection`,
          method: "GET",
          success: (response) => resolve(response.data as TierCollectionEntity),
          fail: (err) => reject(err)
        });
      }
    )
  }

  static getTierCollectionById(collection: number) {
    return new Promise<TierCollectionEntity>(
      (resolve, reject) => {
        wx.request({
          url: `${GlobalService.HOST}${UaTierService.PATH}/collection/${collection}`,
          method: "GET",
          success: (response) => resolve(response.data as TierCollectionEntity),
          fail: (err) => reject(err)
        });
      }
    )
  }

  static getTierDto(tierCollection: number) {
    return new Promise<TierDto[]>(
      (resolve, reject) => {
        wx.request({
          url: `${GlobalService.HOST}${UaTierService.PATH}/dtoV2/${tierCollection}`,
          method: "GET",
          success: (response) => resolve(response.data as TierDto[]),
          fail: (err) => reject(err)
        });
      }
    )
  }

}
